home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-07-15 | 1.4 KB | 60 lines | [TEXT/MPS ] |
- ;
- ; Assembly language routine that does the color mixing
- ;
- ;void MakeRatioRGB(RGBColor *start, RGBColor *end, RGBColor *dest, short percent)
- ;
- ; this is the core of the shade mixing code, it takes to values and a ration
- ; and returns the combination of the colors.
-
- CASE ON
- MakeRatioRGB PROC EXPORT
-
- StackFrame RECORD {A6Link},DECR
- ParamBegin EQU *
- percent ds.l 1 ; make sure parameters are in the
- destRGB ds.l 1 ; correct order for c parameter passing
- endRGB ds.l 1
- startRGB ds.l 1
- ParamSize EQU ParamBegin-*
- RetAddr ds.l 1
- A6Link ds.l 1
- LinkSize EQU *
- ENDR
-
- WITH StackFrame
- LINK A6, #LinkSize
- MakeRatio
- ; dc.w $A9FF ; debugger
- movem.l D7/A2, -(SP)
- movea.l endRGB(A6), A0
- movea.l startRGB(A6), A1
- movea.l destRGB(A6), A2
- move.l percent(A6), D2
-
- mulu #$1111, D2
-
- move.w #2, D0
- @nextChannel
- MOVEQ #0, D1 ; clear high word
- MOVE (A0)+, D1 ; background color component
- SUB (A1), D1 ; change from foreground
- SLO D7 ; remember if it was negated
- BHS.S @orderedOK
- NEG D1 ; flip if subtraction would overflow
- @orderedOK
- mulu D2, D1 ; multiply times scale factor
- SWAP D1 ; divide by 65K
- TST.B D7
- BEQ.S @notFlipped
- NEG.L D1 ; flip it
- @notFlipped
- add.w (A1)+, D1
- move.w D1, (A2)+
- dbra D0, @nextChannel
- movem.l (SP)+, D7/A2
- UNLK A6
- movea.l (SP)+, A0
- ; adda.l #ParamSize, SP ; the c caller does this
- jmp (a0)
-
- END